﻿
function MultiPoints(EventsList) {
    // Creating a LatLng object containing the coordinate for the center of the map
    var myLatlng = new google.maps.LatLng(51.5001525878906, -0.126236200332642);

    // Creating an object literal containing the properties we want to pass to the map  
    var options = {
        zoom: 11,
        scrollwheel: false,
        center: myLatlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        mapTypeControlOptions: { style: google.maps.MapTypeControlStyle.DROPDOWN_MENU },
        navigationControlOptions: { style: google.maps.NavigationControlStyle.SMALL }
    };

    // Calling the constructor, thereby initializing the map  
    var map = new google.maps.Map(document.getElementById('map_canvas_events'), options);

    $.each(EventsList, function(i, myEvent) {
        setupLocationMarker(map, myEvent);
    });
}

function setupLocationMarker(map, myEvent) {

    var contents = "<b><a href='/event/details/" + myEvent.EventID + "'>" +
        myEvent.Title + "</a></b><br />Date: " + Date(myEvent.DateEvent) + "<br />Description: " + myEvent.Description;


    var latlng = new google.maps.LatLng(myEvent.Latitude, myEvent.Longitude);

    // Creating a marker
    var marker = new google.maps.Marker({
        position: latlng,
        map: map,
        title: myEvent.Title
    });

    // Creating an InfowWindow          
    var infowindow = new google.maps.InfoWindow({
        content: contents
    });

    // Adding a click event to the marker
    google.maps.event.addListener(marker, 'click', function() {
        // Opening the InfoWindow
        infowindow.open(map, marker);
  
    });

}

function formatJSONDate(jsonDate) {
    var newDate = jsonDate.format("mm/dd/yyy");    //dateFormat(jsonDate, 'mm/dd/yyyy');
    return newDate;
}
                